package com.demo.zookeeper;

import java.io.IOException;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class ZKExists {

	public static ZooKeeper zk;

	public static Stat existsNode(String path) throws KeeperException, InterruptedException {
		return zk.exists(path, true);
	}

	public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
		zk = ZookeeperConnection.connect();
		String path = "/dataNode";
		Stat stat = existsNode(path);
		if(stat != null) {
			System.out.println("node exists version is " + stat.getVersion());
		} else {
			System.out.println("node not exists");
		}
	}
}
